import Vue from "vue";
import VueRouter from "vue-router";
import LOGIN_VIEWS from '@/router/routes/login';
import HOME_ROUTER from '@/router/routes/home';
import USER_ROUTER from '@/router/routes/userMgmt';
import PHOTO_ROUTER from '@/router/routes/photoMgmt';

Vue.use(VueRouter);

const routes = [
    ...LOGIN_VIEWS, // 登录，注册相关
    ...HOME_ROUTER, // 主页面
    ...USER_ROUTER, // 用户管理
    ...PHOTO_ROUTER //图片管理
];

const publicPath = process.env.NODE_ENV === "production" ? "/boom/" : "/";
const router = new VueRouter({
  mode: 'history',
  base: publicPath,
  routes
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function replace(location) {
    return originalPush.call(this, location).catch(err => err);
};

export default router;
